import axios from 'axios'

document.querySelector('#btn').onclick = async (e) => {
    e.preventDefault(); //阻止默认事件
    const name = document.getElementById('name').value
    const author = document.getElementById('author').value
    const price = document.getElementById('price').value
    const {
        data: res
    } = await axios.post('http://localhost:8080/book', {
        name,
        author,
        price
    })
    if (res.code !== 200) return alert(res.message)
    window.location = './list.html'
}